package router

import (
	"github.com/gin-gonic/gin"
	"server/internal/app/api"
	"server/internal/app/middleware"
)

// AdminNoneLogin 不需要登录
func AdminNoneLogin(r *gin.Engine) {
	//登录
	adminApi := r.Group("/system")
	{
		adminApi.POST("/login", api.LoginApi.Login)                //登录
		adminApi.POST("/refresh_token", api.LoginApi.RefreshToken) //刷新token
		adminApi.POST("/logout", api.LoginApi.Logout)              //登录
		adminApi.POST("/get_avatar", api.LoginApi.GetAvatar)       //登录头像反显

	}
}

// AdminNoneAuth 不需要鉴权
func AdminNoneAuth(r *gin.Engine) {
	//菜单
	adminApi := r.Group("/system/menu", middleware.LoginVerification)
	{
		adminApi.GET("/get_async_routes", api.MenuApi.GetAsyncRoutes) //获取权限菜单列表
		adminApi.GET("/get_select", api.MenuApi.GetSelect)            //远程下拉
	}

	tissueApi := r.Group("/system/tissue", middleware.LoginVerification)
	{

		tissueApi.GET("/get_select", api.TissueApi.GetSelect) //远程下拉
	}

	areaApi := r.Group("/system/area", middleware.LoginVerification)
	{

		areaApi.GET("/get_select", api.AreaApi.GetSelect)                    //远程下拉
		areaApi.GET("/get_select_gradually", api.AreaApi.GetSelectGradually) //远程下拉 逐级
	}

	indexApi := r.Group("/system", middleware.LoginVerification)
	{
		indexApi.GET("/index", api.LoginApi.Index)
	}

	//单位性质
	enterpriseTypeApi := r.Group("/enterprise/enterprise_type", middleware.LoginVerification)
	{
		enterpriseTypeApi.GET("/get_select", api.EnterpriseTypeApi.List)

	}

	//单位性质
	groupApi := r.Group("/system/group", middleware.LoginVerification)
	{
		groupApi.GET("/get_select", api.GroupApi.GetSelect)

	}

}

// AdminRouter 需要鉴权
func AdminRouter(r *gin.Engine) {

	//菜单管理
	adminApi := r.Group("/system/menu", middleware.LoginVerification, middleware.PermissionVerification)
	{
		adminApi.GET("/list", api.MenuApi.List)   //列表
		adminApi.GET("/edit", api.MenuApi.Detail) //反显
		adminApi.POST("/add", api.MenuApi.Add)    //添加
		adminApi.POST("/edit", api.MenuApi.Edit)  //编辑
		adminApi.POST("/del", api.MenuApi.Del)    //删除

	}

	//数据大屏
	dapingApi := r.Group("/system", middleware.LoginVerification, middleware.PermissionVerification)
	{
		dapingApi.GET("/daping", api.Common.Daping) //数据大屏
		dapingApi.GET("/zuo1", api.Common.Zuo1)
		dapingApi.GET("/zuo2", api.Common.Zuo2)
		dapingApi.GET("/zuo3", api.Common.Zuo3)

		dapingApi.GET("/you1", api.Common.You1)
		dapingApi.GET("/you2", api.Common.You2)
		dapingApi.GET("/you3", api.Common.You3)
		dapingApi.GET("/zhong2", api.Common.Zhong2)
	}

	//权限管理
	groupApi := r.Group("/system/group", middleware.LoginVerification, middleware.PermissionVerification)
	{
		groupApi.GET("/list", api.GroupApi.List)   //列表
		groupApi.GET("/edit", api.GroupApi.Detail) //反显
		groupApi.POST("/add", api.GroupApi.Add)    //添加
		groupApi.POST("/edit", api.GroupApi.Edit)  //编辑
		groupApi.POST("/del", api.GroupApi.Del)    //删除

	}

	//后台用户管理
	userApi := r.Group("/system/sys_user", middleware.LoginVerification, middleware.PermissionVerification)
	{

		userApi.GET("/list", api.UserApi.List)   //列表
		userApi.GET("/edit", api.UserApi.Detail) //反显
		userApi.POST("/add", api.UserApi.Add)    //添加
		userApi.POST("/edit", api.UserApi.Edit)  //编辑
		userApi.POST("/del", api.UserApi.Del)    //删除

	}

	//常规管理管理
	routineApi := r.Group("/routine", middleware.LoginVerification, middleware.PermissionVerification)
	{
		//系统配置
		routineApi.GET("/config/index", api.ConfigApi.Detail) //反显
		routineApi.POST("/config/edit", api.ConfigApi.Edit)   //编辑

		routineApi.GET("/user_log", api.LogApi.List)
		routineApi.GET("/get_user_info", api.UserApi.GetUserInfo) //反显
		routineApi.POST("/user_edit", api.UserApi.UserEdit)       //编辑

	}

	//系统日志
	logApi := r.Group("/system/system_log", middleware.LoginVerification, middleware.PermissionVerification)
	{
		logApi.GET("/list", api.LogApi.List)   //列表
		logApi.GET("/edit", api.LogApi.Detail) //反显

	}

	//组织管理
	tissueApi := r.Group("/system/tissue", middleware.LoginVerification, middleware.PermissionVerification)
	{
		tissueApi.GET("/list", api.TissueApi.List)          //列表
		tissueApi.GET("/stat_list", api.TissueApi.StatList) //带统计的列表
		tissueApi.GET("/edit", api.TissueApi.Detail)        //反显
		tissueApi.GET("/get_ids", api.TissueApi.GetIds)     //返回当前组织结构id数组
		tissueApi.POST("/add", api.TissueApi.Add)           //添加
		tissueApi.POST("/edit", api.TissueApi.Edit)         //编辑
		tissueApi.POST("/del", api.TissueApi.Del)           //删除

	}

	//地区管理
	areaApi := r.Group("/system/area", middleware.LoginVerification, middleware.PermissionVerification)
	{
		areaApi.GET("/list", api.AreaApi.List)   //列表
		areaApi.GET("/edit", api.AreaApi.Detail) //反显
		areaApi.POST("/add", api.AreaApi.Add)    //添加
		areaApi.POST("/edit", api.AreaApi.Edit)  //编辑
		areaApi.POST("/del", api.AreaApi.Del)    //删除

	}

	//单位性质
	enterpriseTypeApi := r.Group("/enterprise/enterprise_type", middleware.LoginVerification, middleware.PermissionVerification)
	{
		enterpriseTypeApi.GET("/list", api.EnterpriseTypeApi.List)   //列表
		enterpriseTypeApi.GET("/edit", api.EnterpriseTypeApi.Detail) //反显
		enterpriseTypeApi.POST("/add", api.EnterpriseTypeApi.Add)    //添加
		enterpriseTypeApi.POST("/edit", api.EnterpriseTypeApi.Edit)  //编辑
		enterpriseTypeApi.POST("/del", api.EnterpriseTypeApi.Del)    //删除

	}

	//企业信息
	enterpriseApi := r.Group("/enterprise/enterprise", middleware.LoginVerification, middleware.PermissionVerification)
	{
		enterpriseApi.GET("/list", api.EnterpriseApi.List)   //列表
		enterpriseApi.GET("/edit", api.EnterpriseApi.Detail) //反显
		enterpriseApi.POST("/add", api.EnterpriseApi.Add)    //添加
		enterpriseApi.POST("/edit", api.EnterpriseApi.Edit)  //编辑
		enterpriseApi.POST("/del", api.EnterpriseApi.Del)    //删除

		enterpriseApi.GET("/export", api.EnterpriseApi.Export)  //导出
		enterpriseApi.POST("/import", api.EnterpriseApi.Import) //导入

	}

	//企业信息-修改申请
	enterpriseUpdateApi := r.Group("/enterprise/enterprise_update", middleware.LoginVerification, middleware.PermissionVerification)
	{
		enterpriseUpdateApi.GET("/list", api.EnterpriseUpdateApi.List)        //列表
		enterpriseUpdateApi.GET("/edit", api.EnterpriseUpdateApi.Detail)      //反显
		enterpriseUpdateApi.POST("/add", api.EnterpriseUpdateApi.Add)         //添加
		enterpriseUpdateApi.POST("/edit", api.EnterpriseUpdateApi.Edit)       //编辑
		enterpriseUpdateApi.POST("/del", api.EnterpriseUpdateApi.Del)         //删除
		enterpriseUpdateApi.POST("/passing", api.EnterpriseUpdateApi.Passing) //审核通过
		enterpriseUpdateApi.POST("/reject", api.EnterpriseUpdateApi.Reject)   //审核驳回

	}

	//企业信息-修改申请
	dashboardApi := r.Group("/dashboard", middleware.LoginVerification, middleware.PermissionVerification)
	{
		dashboardApi.GET("/index", api.DashboardApi.Index)

	}

}
